<template>
	<view class="jrdp-box">
		<page-head :transparent='false'>
			<slot slot="title">{{title.length>10?title.substr(0,10)+'...':title}}</slot>
		</page-head>
		<view class="banner">
			<image :src="banner" mode="widthFix"></image>
		</view>
		<view class="imgList" v-for="(item, i) in imgList" :key="i">
			<image :src="item.img" mode="widthFix" @click="linkTo(item.link)"></image>
		</view>
	</view>
</template>

<script>
	import jrdp1 from '../../static/img/jrdp/jrdp1.png'
	import jrdp2 from '../../static/img/jrdp/jrdp2.png'
	import jrdp3 from '../../static/img/jrdp/jrdp3.png'
	import jrdp4 from '../../static/img/jrdp/jrdp4.png'
	import jrdp5 from '../../static/img/jrdp/jrdp5.png'
	import jrdp6 from '../../static/img/jrdp/jrdp6.png'
	import jrdp7 from '../../static/img/jrdp/jrdp7.png'
	import jrdp8 from '../../static/img/jrdp/jrdp8.png'
	import jrdp9 from '../../static/img/jrdp/jrdp9.png'
	import jrdp10 from '../../static/img/jrdp/jrdp10.png'
	import jrdp11 from '../../static/img/jrdp/jrdp11.png'

	export default {
		data() {
			return {
				title: '今日大牌',
				banner: jrdp1,
				imgList: [{
						img: jrdp2,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=C6YAbYLe%2B%2Fy1wkUOrOo%2Be9gfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					},
					{
						img: jrdp3,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=W%2FBQPoKDrvm1wkUOrOk0fNgfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					},
					{
						img: jrdp4,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=XaBRPtaGqv21wkUOrOk0etgfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					},
					{
						img: jrdp5,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=DvBXPNWFqPu1wkUOrOk0fdgfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					},
					{
						img: jrdp6,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=C6JdPYPTqPy1wkUOrOk1f9gfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					},
					{
						img: jrdp7,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=CqdWa4XW9fu1wkUOrOk1fNgfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					},
					{
						img: jrdp8,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=XaBVOtfX%2FKq1wkUOrOk1fdgfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					},
					{
						img: jrdp9,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=B6dTPIrVrvm1wkUOrOk1etgfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					},
					{
						img: jrdp10,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=CKcBbYLU%2Fq61wkUOrOk1e9gfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					},
					{
						img: jrdp11,
						link: 'https://frontend.sqqmall.com/cate/cate-detail.html?rq=W6AAP4KDqPu1wkUOrOk1eNgfOcHCT7%2FoyB%2FW5pwtPs%2B0lmCU'
					}
				]
			}
		},
		onLoad() {
			this.genCommonData()
		},
		methods: {
			genCommonData() {
				const that = this
				let url = window.location.href;
				// console.log("url===" + url);
				let reg_url = /^[^\?]+\?([\w\W]+)$/,
					reg_para = /([^&=]+)=([\w\W]*?)(&|$|#)/g,
					arr_url = reg_url.exec(url),
					ret = {};
				if (arr_url && arr_url[1]) {
					let str_para = arr_url[1],
						result;
					while ((result = reg_para.exec(str_para)) != null) {
						ret[result[1]] = result[2];
					}
				}
				let token = ret.bump;
				if (token != '' && token != 'null' && token != null && token != undefined && token != 'undefined') {
					uni.setStorageSync('token', decodeURI(ret.token));
					uni.setStorageSync('bump', ret.bump);
				} else {
					onStartLogin();
				}
			},
			linkTo(url) {
				if (url !== '') {
					let link = decodeURI(url)
					let bump = uni.getStorageSync('bump')
					bump = decodeURI(bump)
					link = link + '&fromapp=1&bump=' + bump + '&disable_order_direct_discount=1'
					// window.location.href = link
					// console.log(link)
					appNavigateTo(link);
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.jrdp-box {
		width: 100%;

		.banner {
			width: 100%;
			overflow: hidden;
			overflow-y: auto;

			image {
				width: 100%;
				display: block;
			}
		}

		.imgList {
			width: 100%;
			overflow: hidden;
			overflow-y: auto;

			image {
				width: 100%;
				display: block;
			}
		}
	}
</style>
